using System;
using System.Data;

namespace PHSRAG.Insight21.FormsManagement.Serialization
{
	/// <summary>
	/// This class abstracts the notion of sign off information on the pdf
	/// </summary>
	public class FormSignature
	{
		#region Private instance variables
		private string activity = string.Empty;
		private string name = string.Empty;
		private string degree = string.Empty;
		private string dateAuthenticated = string.Empty;
		#endregion

		#region Properties
		/// <summary>
		/// Gets or sets the role of person signing off
		/// </summary>
		public string Activity
		{
			get { return activity; }
			set { activity = value; }
		}
		
		/// <summary>
		/// Gets or sets the name of the person signing off
		/// </summary>
		public string Name
		{
			get { return name; }
			set { name = value; }
		}

		/// <summary>
		/// Gets or sets the degree of the person signing off
		/// </summary>
		public string Degree
		{
			get { return degree; }
			set { degree = value; }
		}

		public string NameAndDegree
		{
			get { return (degree != string.Empty) ? (name + ",  " + degree) : name; }
			set { }
		}

		/// <summary>
		/// Gets or sets the date on which the person signed off
		/// </summary>
		public string DateAuthenticated
		{
			get { return dateAuthenticated; }
			set { dateAuthenticated = value; }
		}
		#endregion

		#region Constructors
		/// <summary>
		/// Default constructor
		/// </summary>
		public FormSignature()
		{
		}

		/// <summary>
		/// Default constructor
		/// </summary>
		public FormSignature(DataRow dr)
		{
			if (dr.Table.Columns.Contains("ActivityName"))
				activity = dr["ActivityName"].ToString();

			if (dr.Table.Columns.Contains("FullName"))
				name = dr["FullName"].ToString();

			if (dr.Table.Columns.Contains("Degree"))
			{
				object o = dr["Degree"];
				if (o != DBNull.Value)
					degree = dr["Degree"].ToString();
			}

			if (dr.Table.Columns.Contains("DateAuthenticated"))
			{
				object o = dr["DateAuthenticated"];
				if (o != DBNull.Value)
					dateAuthenticated = ((DateTime)dr["DateAuthenticated"]).ToString("MMMM dd, yyyy");
			}

		}
		#endregion
	}
}
